package com.quanyan.stadium.web.api.v2;

import com.quanyan.api.APIResponse;
import com.quanyan.common.Plugin.PageObj;
import com.quanyan.stadium.api.req.ReqId;
import com.quanyan.stadium.api.req.v2.ReqGameEventOrder;
import com.quanyan.stadium.service.gameEventOrder.GameEventOrderService;
import io.netty.handler.codec.http.HttpRequest;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

/**
 * Created by lenovo on 2017/3/3.
 */
@RestController
@RequestMapping("/api/stadium/gameEventOrder")
public class GameEventOrderController {

    @Autowired
    GameEventOrderService gameEventOrderService;

    /**
     *
     * 赛事订单列表
     *
     */
    @RequestMapping(value="/getGameEventOrderList", method = RequestMethod.POST)
    public APIResponse<?> gameCategoryAndSystem(@RequestBody ReqGameEventOrder reqGameEventOrder, HttpServletRequest request,BindingResult result)  {
        if(result.hasErrors()) {
            return APIResponse.returnFail(result.getFieldError().getDefaultMessage());
        }
        int uid = (int)request.getAttribute("uid");
        reqGameEventOrder.setUid(uid);
        return APIResponse.returnSuccess(PageObj.create(0, reqGameEventOrder.getPageNo(), reqGameEventOrder.getPageSize(), gameEventOrderService.getGameEventOrderList(reqGameEventOrder)));
    }

}
